<cfcomponent>

	<cfscript>
		this.name = "Calgrants_Mobile";
		this.clientManagement = false;
		this.sessionManagement = false;
		this.applicationTimeout = CreateTimeSpan(100,0,0,0);
		if (cgi.HTTP_HOST eq "www.calgrants.org" or cgi.HTTP_HOST eq "calgrants.org"){
			this.datasource = "wms";
		} else {
			this.datasource = "wms_dev";
		}
	</cfscript>
	
	<cffunction name="onApplicationStart">
		<cfscript>
			if (cgi.HTTP_HOST eq "www.calgrants.org" or cgi.HTTP_HOST eq "calgrants.org"){
				application.mode = "prod";
			} else {
				application.mode = "dev";
			}
			application.pathToApplication = "/m";
			application.pathToComponents = "assets.calgrants.com";
			application.pathToBO = application.pathToComponents & ".bo";
			application.pathToServices = application.pathToComponents & ".service";
			application.pathToGateways = application.pathToComponents & ".gateway";
			application.pathToUI = "/assets/calgrants/ui";
			application.pathToJQuery = "/assets/jquery/jquery.min.js";
			application.pathToJQueryUI = "/assets/jquery/jquery-ui.min.js";
			application.pathToJQueryMobile = "/assets/jquery/jquery.mobile-1.1.1.min.js";
			application.pathToJQueryMobileCSS = "/assets/jquery/jquery.mobile-1.1.1.min.css";
			application.pathToKendo = "/assets/kendoui/js/kendo.all.min.js";
			application.pathToKendoDefaultCSS = "/assets/kendoui/styles/kendo.default.min.css";
			application.pathToKendoCommonCSS = "/assets/kendoui/styles/kendo.common.min.css";
			application.pathToBootstrap = "/assets/bootstrap/js/bootstrap.min.js";
			application.pathToBootstrapCSS = "/assets/bootstrap/css/bootstrap.min.css";
			application.facebookConnectCDNUrl = "//connect.facebook.net/en_US/all.js##xfbml=1&appId=247559268643341";
			application.apiUrl = "/assets/calgrants/com/API.cfc";
			application.personality = {};
			application.personality.name = "Cash for College";
			application.personality.email = "cashforcollege@csac.ca.gov";
			application.personality.bcc = "cash4collegeca@gmail.com";
			application.developer = {};
			application.developer.name = "Syntric";
			application.developer.email = "kenhobbs@gmail.com";
			application.currentProgramYear = "2012-2013";
			application.initDateTime = now();
		</cfscript>
	</cffunction>
	
	<cffunction name="onRequestStart">
	
		<cfset request.alerts = ArrayNew(1) />
	
		<cfif IsDefined("initApp")>
			<cfscript>
				onApplicationStart();
			</cfscript>
		</cfif>
		
		<cflock scope="application" timeout="20" type="readonly">
			<cfset StructAppend(request, application) />
		</cflock>
	
	</cffunction>
	
	<cffunction name="onError">
		<cfargument name="Exception" required="true" />
		<cfargument name="EventName" required="true" />
		<cfif application.mode eq "prod">
			<cfmail to="kenhobbs@gmail.com" from="kenhobbs@gmail.com" subject="Mobile Site Error" type="html">
				<cfdump var="#arguments.Exception#" label="Exception">
				<cfdump var="#application#" label="Application">
				<cfdump var="#form#" label="Form">
				<cfdump var="#request#" label="Request">
			</cfmail>
		<cfelse>
			<cfdump var="#arguments.Exception#" expand="no" label="Exception">
			<cfdump var="#application#" label="Application">
			<cfdump var="#form#" expand="no" label="Form">
			<cfdump var="#request#" expand="no" label="Request">
		</cfif>
		<h1>Ooops</h1>
		<p>The application has encountered an error.  An error message has been sent to the developer.</p>
		<p>If you require immediate assistance with this error, please <a href="mailto:support@syntric.com">contact the developer</a>.</p>
		<cfabort>
	</cffunction>
	
	<cffunction name="onRequestEnd">
        <cfsetting showdebugoutput="no">
    </cffunction>

</cfcomponent>